#
# ShoeBox
#  A start product for Plone - ShoeBox
#
# ShoeBox.py
#  Validation
#
# Author: Christian Koller <admin@iecw.net>
#
# Released under GNU GPL v2 or later
#

from Products.validation.interfaces import ivalidator

##
## Tests if the value is one of the allowed values
##
class AllowedUrl:
	__implements__ = (ivalidator,)

	def __init__(self, name, allowed):
		self.name = name
		self.allowed = allowed

	def __call__(self, value, *args, **kwargs):

		if self.allowed.count(value) > 0:
			return True
		else:
			return ("""
			Error: '%(value)s' is not a allowed access mode. Use one off: %(allowed)s.
			""" % {'value': value, 'allowed': self.allowed})